<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<title>登录</title>
		<link rel="stylesheet" href="Common/assets/css/bootstrap.css">
		<link rel="stylesheet" href="css/animate.css">
		<link rel="stylesheet" href="css/loginstyle.css">
		<link rel="stylesheet" type="text/css" href="Common/simpleAlert/css/simpleAlert.css">
		<!-- jQuery -->
		<script src="Common/assets/js/jquery-1.10.2.js"></script>
		<!-- Modernizr JS -->
		<script src="js/modernizr-2.6.2.min.js"></script>
		<script type="text/javascript" src="Common/simpleAlert/js/simpleAlert.js"></script>
		<script type="text/javascript" src="js/Common.js"></script>
		<!-- FOR IE9 below -->
		<!--[if lt IE 9]>
		<script src="js/respond.min.js"></script>
		<![endif]-->
	</head>

	<body style="min-height: 750px;">
		<div class="container" style="min-height: 750px;">
			<div class="row">
				<div class="col-md-5 col-md-push-8">
					<form action="#" class="fh5co-form animate-box" data-animate-effect="fadeInRight">
						<h7>用户登录</h7>
						<div class="form-group">
							<label for="username" class="sr-only">登录名：</label>
							<input type="text" class="form-control" value="" id="username" placeholder="Username" autocomplete="off">
						</div>
						<div class="form-group">
							<label for="password" class="sr-only">密码：</label>
							<input type="password" class="form-control" value="" id="password" placeholder="Password" autocomplete="off">
						</div>
						<div class="form-group">
							<label for="password" class="sr-only">验证码</label>
							<input type="text" class="form-control" id="captcha" placeholder="CaptCha" autocomplete="off">
						</div>
						<div class="form-group">
							<img src="https://www.slivercloud.cn/chinamobile/captcha.jpg" id="img" onclick="UpdateCaptCha()">
						</div>
						<div class="form-group">
							<input style="width: 100%;" onclick="login()" value="登    录" class="btn btn-primary">
						</div>
					</form>
				</div>
			</div>
		</div>
		<div style="height: 55px;width: 100%;background-color: #535353;position:fixed;bottom:0px;padding-left: 50px;line-height: 55px;color: #fff;">
			<span>版权所有</span>
		</div>
	</body>
	<script>
		$(function() {
			UpdateCaptCha();
			document.onkeydown = function(e) {
				var ev = document.all ? window.event : e;
				if(ev.keyCode == 13) {
					login();
				}
			}
		});

		function login() {
			var num = Math.random();
			var data = {
				"username": $("#username").val(),
				"password": $("#password").val(),
				"captcha": $("#captcha").val(),
				"isPhone":2
			}
			$.ajax({
				url: GLOBAL.URL + "/sys/login?" + num,
				type: "post",
				data: data,
				dataType: "json",
				ContentType: 'application/json',
				xhrFields: {
					withCredentials: true
				},
				crossDomain: true,
				success: function(msg) {
					if(msg.code != "0") {
						AlertInfo("操作失败！" + msg.msg);
						UpdateCaptCha();
					} else {
						var area="";
						debugger;
						if(msg.user_info.deptId==1){
							area=msg.user_info.cityName;
						}else{
							area=msg.user_info.countryName;
						}
						var userId=msg.user_info.userId;
						window.location.href = "index.html?dept="+msg.user_info.deptId+"&user="+userId+"&userName="+$("#username").val()+"&area="+encodeURI(encodeURI(area));
					}
				}
			})
		}

		function UpdateCaptCha() {
			var num = Math.random();
			$("#img").attr("src", GLOBAL.URL + "/captcha.jpg?" + num);
		}
	</script>

	<!-- Bootstrap -->
	<script src="Common/assets/js/bootstrap.min.js"></script>
	<!-- Placeholder -->
	<script src="js/jquery.placeholder.min.js"></script>
	<!-- Waypoints -->
	<script src="js/jquery.waypoints.min.js"></script>
	<!-- Main JS -->
	<script src="js/main.js"></script>

</html>